/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pingouin;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Hippolyte
 */
public class TClientCoord extends Thread {

    public int x;
    public int y;
    public final String awake = new String();

    @Override
    public void run() {

        while (true) {

            PrintWriter pred = null;
            try {
                Socket socket = new Socket(Partie.adresseServeur, TServeurCoord.PORT);

                pred = new PrintWriter(
                        new BufferedWriter(
                        new OutputStreamWriter(socket.getOutputStream())),
                        true);

                pred.println(x + ";" + y);
                System.out.println(x + ";" + y);
                pred.close();
                socket.close();
            } catch (IOException ex) {
                Logger.getLogger(TClientCoord.class.getName()).log(Level.SEVERE, null, ex);
            }

            synchronized (awake) {
                try {
                    awake.wait();
                } catch (InterruptedException ex) {
                    Logger.getLogger(TClientCoord.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

        }
    }
}
